﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ZeCloud.Resto55.Business.Table;
using ZeCloud.Resto55.Business;
using System.Drawing;
using System.Web.UI.SilverlightControls;

namespace Resto55Business_WebRole
{
    public partial class Price : System.Web.UI.Page
    {
        //protected void OnPreInit(EventArgs e)
        //{

        //    SilverlightChart.InitParameters = "elementId=" + Request.QueryString["id"];
        //}

        //protected void OnPreLoad(EventArgs e)
        //{
        //    SilverlightChart.InitParameters = "elementId=" + Request.QueryString["id"];
        //}

        protected void Page_Load(object sender, EventArgs e)
        {
            string elementId = Request.QueryString["id"];
            if (string.IsNullOrEmpty(elementId))
                Response.Redirect("/");
            InitializeSilverlightChart();
        }

        private void InitializeSilverlightChart()
        {
            Silverlight silverlight = new Silverlight();
            silverlight.Source = "~/ClientBin/SilverlightChartDisplay.xap";
            silverlight.MinimumVersion = "2.0.31005.0";
            silverlight.Height = new Unit("300");
            silverlight.Width = new Unit("600");
            silverlight.InitParameters = "elementId=" + Request.QueryString["id"];
            silverlight.Visible = true;
            silverlight.Enabled = true;
            silverlight.Windowless = true;
            silverlight.PluginBackground = Color.Transparent;
            SilverlightDiv.Controls.Add(silverlight);
        }

        protected void Label1_Load(object sender, EventArgs e)
        {
            RestoService RestoServ = BusinessFacade.CreerFacade().GetRestoService();
            double prix=RestoServ.RechercherPrixMoyenPourElement(Request.QueryString["id"]);
            if (prix != 0)
            {
                ((Label)sender).Text += prix + " €";
            }
        }
    }
}
